﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html>
<html lang="en">
<head>
<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
<link type="text/css" rel="stylesheet" href="<%=contextPath %>/static/bootstrap-fileinput/css/fileinput.css" />
<script type="text/javascript" src="<%=contextPath %>/static/bootstrap-fileinput/js/fileinput.js"></script>
<script type="text/javascript" src="<%=contextPath %>/static/bootstrap-fileinput/js/locales/zh.js"></script>
<script type="text/javascript" src="<%=contextPath %>/plugins/zTree_v3/js/jquery.ztree.core.min.js"></script>
<script type="text/javascript" src="<%=contextPath %>/plugins/zTree_v3/js/jquery.ztree.excheck.min.js"></script>
</head>
<body>
	<div class="container-fluid" id="main-container">
		<div id="page-content" class="clearfix">
			<div class="row-fluid">
				<div class="col-sm-12" id="main">
					<form class="form-horizontal" id="signupForm" role="form" method="post" enctype="multipart/form-data">
					<input type="hidden" name="id"  id="id" value="${id }" />
						<fieldset>
							<legend>基本资料</legend>
							<div class="form-group">
								<!-- Select Basic -->
								<label class="col-sm-2 control-label">类型：</label>
								<div class="col-sm-4">
									<select class="form-control" name="type">
										<c:forEach items="${fns:getDictList('resume_type')}"
											var="temp1">
											<option value="${temp1.value }">${temp1.valueName }</option>
										</c:forEach>
									</select>
								</div>
								<label class="col-sm-2 control-label">行业：</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" id="industryName"
										onclick="openTree('industry');" placeholder="请选择行业"
										readonly="readonly"  name="industryNames"/> <input type="hidden" name="industryId"
										id="industryId" />
									<p class="help-block">最多可选三个行业，多选无效。</p>
								</div>
							</div>
							<div class="form-group">
							    <label class="col-sm-2 control-label">真实姓名：</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" id="name" name="trueName" value="${workSearch.trueName }"/>
									<p class="help-block" style="color: red;">*必填项，姓名具有唯一性，不可重复添加，如姓名存在请联系管理员。</p>
								</div>
								<label class="col-sm-2 control-label">手机号码：</label>
								<div class="col-sm-4 form-inline" id="phoneinput">
				                     <input type="tel" class="form-control" id="phone"
										name="cellphone" value="${workSearch.contact }"  maxlength="11" placeholder="请输入工作号码" onblur="verifyName()"/>
									 <p class="help-block" style="color: red;">*必填项，请输入手机号码，如手机号存在请联系管理员。</p>
									 <input type="tel" class="form-control" id="lifephone"
										name="lifephone"  maxlength="11" placeholder="生活号码非必填项" onblur="isPhone('lifephone',this.value)"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">性别：</label>
								<div class="col-sm-4">
									<label class="radio-inline"> 
									<input value="1" name="sex" type="radio" <c:if test="${workSearch.sex=='男'}">checked="checked"</c:if>> 男
									</label> 
									<label class="radio-inline"> 
									<input value="2" name="sex" type="radio" <c:if test="${workSearch.sex=='女'}">checked="checked"</c:if>> 女
									</label>
									<p class="help-block" style="color: red;">*必填项，请输入性别。</p>
								</div>
								<label class="col-sm-2 control-label">婚姻状况：</label>
								<div class="col-sm-4 form-inline">
									<select class="form-control" name="conditions" id="conditions">
										<c:forEach items="${fns:getDictList('resume_conditions')}"
											var="temp" varStatus="vs">
											<option value="${temp.value }">${temp.valueName }</option>
										</c:forEach>
									</select>
									<input type="text" class="form-control" id="maritalOther"  style="display: none;"
										name="maritalOther" value="" placeholder="请输入其他婚姻状况"/>
									 <label class="radio-inline"> <input type="checkbox" name="isSecret" value="1">保密
									</label>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">出生日期：</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" id="birthdate"
										name="birthdate" readonly="readonly" placeholder="请选择日期" value="1980-01-01" onClick="WdatePicker()"/>
									<p class="help-block" style="color: red;">*必填项，请输入出生日期。系统年龄为:${workSearch.age}</p>
								</div>
								<label class="col-sm-2 control-label">身份证号：</label>
								<div class="col-sm-4">
									<input type="number"  id="idCard" name="idCard" class="form-control" onblur="isIdCard('idCard',this.value)" />
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">身高：</label>
								<div class="col-sm-4 form-inline">
									<input type="text" class="form-control" id="stature" name="stature" onblur="isInteger('stature',this.value)"/>（	cm）
								</div>
								<label class="col-sm-2 control-label">体重：</label>
								<div class="col-sm-4 form-inline">
									<input type="text" class="form-control" id="weight" name="weight" onblur="isInteger('weight',this.value)"/>（kg）
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">民族：</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" id="ethnic" name="ethnic" value="汉"/>
								</div>
								<label class="col-sm-2 control-label">健康状况：</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" id="health" name="health" value="良好"/>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">邮箱：</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" id="email" name="email"
										value="${workSearch.email }" onblur="verifyName()"/>
								    <p class="help-block" style="color: red;">*必填项，请输入邮箱，如邮箱存在请联系管理员。</p>
								</div>
								<label class="col-sm-2 control-label">QQ：</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" id="qq" name="qq" />
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">微信：</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" id="wechat"
										name="wechat" />
								</div>
								<label class="col-sm-2 control-label">领英：</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" id="linkedin" name="linkedin" />
								</div>
							</div>
							<div class="form-group">
							    <label class="col-sm-2 control-label">国籍：</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" id="nationality"
										name="nationality" value="中国" />
								</div>
								<label class="col-sm-2 control-label">籍贯：</label>
								<div class="col-sm-4">
								    <select  id="province" name="natives" class="selectpicker show-tick form-control"  data-live-search="true"></select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">户口所在地：</label>
								<div class="col-sm-4 form-inline">
									<select  id="prov"  class="form-control"  style="width:40%;"></select>
									<select  id="city" name="household" class="form-control"  style="width:50%;display:none;" ></select>
								</div>
								<label class="col-sm-2 control-label">目前居住城市：</label>
								<div class="col-sm-4 form-inline">
								<select  id="provnow"  class="form-control"  style="width:40%;"></select>
								<select  id="citynow" name="location" class="form-control"  style="width:50%;display:none;" ></select>
								<p class="help-block" style="color: red;">*必填项，请输入目前居住城市。</p>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">期望工作城市：</label>
								<div class="col-sm-4">
								   <select id="provexp" class="form-control"></select>
								   <input type="text" class="form-control" id="areaName" placeholder="请选择区域"
										readonly="readonly"  name="expectedCityNames" style="display:none;margin-top: 5px;" onclick="openTree('area')"/>
								   <input type="hidden" name="expectedCity" id="areaId" />
										<p class="help-block" style="color: red;">*必填项，最多可选三个城市，多选无效。</p>
								</div>
								<label class="col-sm-2 control-label">目前岗位：</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" id="position" name="position" />
									<p class="help-block" style="color: red;">*必填项，请输入目前岗位名称。</p>
								</div>
							</div>
							<div class="form-group">
								<!-- Select Basic -->
								<label class="col-sm-2 control-label">目前年薪：</label>
								<div class="col-sm-4 form-inline">
									<input type="text" class="form-control" id="emolument"
										name="emolument"  onblur="isIntDec('emolument',this.value);" />（万人民币）
										<p class="help-block" style="color: red;">*必填项，请输入目前年薪。</p>
										<input type="text" class="form-control" id="basicSalary"
										name="basicSalary"  onblur="isIntDec('basicSalary',this.value);" placeholder="请输入基本年薪" />（万人民币）
										<p class="help-block" >请输入基本年薪。</p>	
										<input type="text" class="form-control" id="bonus"
										name="bonus"  onblur="isIntDec('bonus',this.value);" placeholder="请输入奖金" />（万人民币）
										<p class="help-block" >请输入奖金。</p>	
										<input type="text" class="form-control" id="equity"
										name="equity" placeholder="请输入股权/期权" />
										<p class="help-block" >请输入股权/期权。</p>	
								</div>
								<label class="col-sm-2 control-label">期望年薪：</label>
								<div class="col-sm-4 form-inline">
									<input type="text" class="form-control" id="expectSalarystart"
										name="expectSalarystart" onblur="isIntDec('expectSalarystart',this.value);" /> 
										<p class="help-block" >--至--</p>	
									<input type="text"
										class="form-control" id="expectSalaryend" name="expectSalaryend"
										 onblur="isIntDec('expectSalaryend',this.value);" />（万人民币）
									<p class="help-block" style="color: red;">*必填项，请输入期望年薪。</p>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">第一学历：</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" id="education"
										name="education" value="${resume.education }" />
									<p class="help-block" style="color: red;">*必填项，请输入第一学历。</p>
								</div>
								<label class="col-sm-2 control-label">专业：</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" id="profession"
										name="profession" />
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">最高学历：</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" id="highestEdu"
										name="highestEdu" value="${resume.highestEdu }" />
									<!-- <p class="help-block" style="color: red;">*必填项，请输入第一学历。</p> -->
								</div>
								<label class="col-sm-2 control-label">专业(最高学历)：</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" id="highestPro"
										name="highestPro" />
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">目前状态</label>
								<div class="col-sm-4">
								    <select class="form-control" name="status">
								        <c:forEach items="${fns:getDictList('resume_status')}"
											var="temp" varStatus="vs">
											<option value="${temp.value }">${temp.valueName }</option>
										</c:forEach>
									</select>
								</div>
								<label class="col-sm-2 control-label">标签：</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" id="tagName" name="tag"
										placeholder="请选择标签" readonly="readonly"
										onclick="openTree('tag')" /> <input type="hidden"
										class="form-control" id="tagId" name="tagIds" />
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">自我评价：</label>
								<div class="col-sm-4">
									<textarea rows="3" cols="2" class="form-control" id="advantage"
										name="advantage" ></textarea>
								</div>
								<label class="col-sm-2 control-label">备注：</label>
								<div class="col-sm-4">
								 <textarea rows="3" cols="2" class="form-control" id="remark"
										name="remark" ></textarea>
								 <p class="help-block">填写内容如不看哪些公司，哪些区域，哪些老板</p>
								</div>
							</div>
							<div class="form-group">
								<!-- <label class="col-sm-2 control-label">资格证书：</label>
								<div class="col-sm-4">
									<input type="text" class="form-control" id="signature" name="signature"  />
								</div> -->
								<label class="col-sm-2 control-label">工作语言：</label>
								<div class="col-sm-4">
								<input type="text" class="form-control" id="languageName"
										onclick="openTree('language');" placeholder="请选择语言"
										readonly="readonly"  name="language"/>
										<input type="hidden" name="languageids" id="languageId" />
										<p class="help-block">最多可选三个语言，多选无效。</p>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">证件照：</label>
								<div class="col-sm-4">
									<input type="file" name="file" id="headPic"/>
									<input type="hidden" id="headPic1" name="headPic" />
								</div>
								<label class="col-sm-2 control-label">生活照：</label>
								<div class="col-sm-4">
									<input type="file" name="file"  id="lifePhoto"/>
									<input type="hidden" name="lifePhoto" id="lifePhoto1" />
								</div>
							</div>
						</fieldset>
						<div class="form-group" style="text-align: center;">
							<div class="col-sm-12">
								<button class="btn btn-primary" type="button" id="sub">提交</button>
							</div>
						</div>
						<fieldset id="addexper" style="display: none;">
							<legend>附属资料</legend>
							<div class="form-group">
								<label class="col-sm-2 control-label">工作经历：</label>
								<div class="col-sm-10 form-inline">
									<button type="button" class="btn btn-info"
										onclick="addExperience('work');">增加</button>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">教育经历：</label>
								<div class="col-sm-10 form-inline">
									<button type="button" class="btn btn-info"
										onclick="addExperience('edu',1);">增加</button>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-2 control-label">培训经历：</label>
								<div class="col-sm-10 form-inline">
									<button type="button" class="btn btn-info"
										onclick="addExperience('edu',2);">增加</button>
								</div>
							</div>
							<s:hasPermission name="talentsRecommend:add">
							<div class="form-group">
								<label class="col-sm-2 control-label">沟通记录：</label>
								<div class="col-sm-10 form-inline">
									<button type="button" class="btn btn-info"
										onclick="addExperience('demandCommunicate');">增加</button>
								</div>
							</div>
							</s:hasPermission>
						</fieldset>
					</form>
				</div>
				<!-- PAGE CONTENT ENDS HERE -->

			</div>
			<!--/row-->
		</div>
		<!--/#page-content-->
	</div>
	<!--/.fluid-container#main-container-->
<script type="text/javascript">
$(function () {
	$("#file-3").fileinput({
		language : 'zh',
		showUpload: false,
		showCaption: false,
		browseClass: "btn btn-primary",
		fileType: "any",
        previewFileIcon: "<i class='glyphicon glyphicon-king'></i>"
	});
	initFileInput("headPic");
	initFileInput("lifePhoto");
    $(".form_datetime").datetimepicker({
    	autoclose: true,
        minView: "month", //选择日期后，不会再跳转去选择时分秒
        language: 'zh-CN',
        format: "yyyy-mm-dd",
        forceParse: 0,
        pickTime: false,
        pickerPosition: "bottom-right",
        //initialDate:now,
        onSelect: function (dateText, inst) {
            // 不做任何处理
        }
    });
    //$("#birthdate").datetimepicker("update","1980-01-01");//赋值
    
    $("#conditions").change(function(){
    	var id = $(this).val();
    	console.log(id);
    	if(id==4){
    		$("#maritalOther").show();
    	}else {
    		$("#maritalOther").hide();
		}
    });
    $("#sub").click(function () {
    	//批量验证表单非空
    	//调用方式
    	var arr=new Array(
    	  new Array('type','类型未选择!'),
    	  new Array('industryName','行业未选择!'),
    	  //new Array('name','昵称未填写!'),
    	  new Array('name','真实姓名未填写!'),
    	  /* new Array('ethnic','民族未填写!'), */
    	  new Array('health','健康状况未填写!'),
    	  /* new Array('stature','身高未填写!'), */
    	  /* new Array('weight','体重未填写!'), */
    	  new Array('natives','籍贯未填写!'),
    	  new Array('household','户口所在地未填写!'),
    	  new Array('birthdate','出生日期未填写!'),
    	  new Array('sex','性别未选择!'),
    	  /* new Array('signature','资格证书未填写!'), */
    	  new Array('position','目前岗位未填写!'),
    	  new Array('conditions','婚姻状况未选择!'),
    	  new Array('education','学历未填写!'),
    	  new Array('emolument','目前年薪未填写!'),
    	  new Array('expectSalarystart','期望年薪未填写!'),
    	  new Array('expectSalaryend','期望年薪未填写!'),
    	  new Array('location','目前在所城市未选择!'),
    	  new Array('citySel','期望工作城市未选择!'),
    	  new Array('email','邮箱未填写!'),
    	  /* new Array('wechat','微信未填写!'), */
    	  /* new Array('qq','QQ未填写!'), */
    	  new Array('profession','专业未填写!'),
    	  /* new Array('linkedin','领英未填写!'), */
    	  new Array('tag','标签未选择!')
    	);
    	  for(var i=0;i<arr.length;i++){
        	  if($("#"+arr[i][0]).val()==''){
        		  $("#"+arr[i][0]).tips({
  					side:3,
  		            msg:arr[i][1],
  		            bg:'#AE81FF',
  		            time:1
  		        });
        		  $("#"+arr[i][0]).focus();
  				return;
  			}
    	};
    	$("#signupForm").ajaxSubmit({
           url: '<%=contextPath%>/resume/add',
			type : 'post',
			dataType : "json",
			success : function(data) {
				if (data.code == 200) {
					swal({ 
					  title: "确认是否继续添加相关经历！", 
					  type: "warning",
					  showCancelButton: true, 
					  confirmButtonColor: "#DD6B55",
					  confirmButtonText: "确认", 
					  cancelButtonText: "取消",
					  closeOnConfirm: false, 
					  closeOnCancel: false				
					},
					function(isConfirm){ 
					  if (isConfirm) { 
						  $("#sub").attr("disabled","disabled");
						  $("#addexper").show();
						  swal({ 
							  title: "自动关闭弹窗！", 
							  text: "1秒后自动关闭。", 
							  timer: 1000, 
							  showConfirmButton: false 
							});
						  location.hash="#addexper";
					  } else { 
						  window.location.href = "<%=contextPath%>/resume/list";
					  } 
					});
				} else {
					swal("错误", data.message, "error");
				}
			}
		});
		});
	$.ajax({//查询省
		url:"<%=contextPath%>/area/getAreaJson",
		data:{pid:0,level:1},
		type:"post",
		dataType:"json",
		success:function(data){
			var htm='';
			$("#province").append('<option value="">==请选择省直辖市==</option>');
			$("#prov").append('<option value="">==请选择省直辖市==</option>');
			$("#provnow").append('<option value="">==请选择省直辖市==</option>');
			$("#provexp").append('<option value="">==请选择省直辖市==</option>');
			$.each(data,function(i,item){
				$("#province").append("<option value='" + item.id + "'>" + item.name + "</option>");
				$("#prov").append("<option value='" + item.id + "'>" + item.name + "</option>");
				$("#provnow").append("<option value='" + item.id + "'>" + item.name + "</option>");
				$("#provexp").append("<option value='" + item.id + "'>" + item.name + "</option>");
			});
			$('.selectpicker').selectpicker({  
			    'selectedText': 'cat'  
			});
		}
	});	
	$("#prov").change(function(){//查询市
		var pid = $(this).val();
		var city = $("#city");
		$("#city").show();
		if($("#city").children().length > 0) {
			city.empty();
		}
		$.ajax({//查询省
			url:"<%=contextPath%>/area/getAreaJson",
			data:{pid:pid,level:2},
			type:"post",
			dataType:"json",
			success:function(data){
				$("#city").append('<option value="">==请选择市州区==</option>');
				$.each(data,function(i,item){
					$("#city").append("<option value='" + item.id + "'>" + item.name + "</option>");
				});
				$('.selectpicker').selectpicker({  
				    'selectedText': 'cat'  
				});
			}
		})
	});
	$("#provnow").change(function(){//查询市
		var pid = $(this).val();
		var citynow = $("#citynow");
		$("#citynow").show();
		if($("#citynow").children().length > 0) {
			citynow.empty();
		}
		$.ajax({//查询省
			url:"<%=contextPath%>/area/getAreaJson",
			data:{pid:pid,level:2},
			type:"post",
			dataType:"json",
			success:function(data){
				$("#citynow").append('<option value="">==请选择市州区==</option>');
				$.each(data,function(i,item){
					$("#citynow").append("<option value='" + item.id + "'>" + item.name + "</option>");
				});
				$('.selectpicker').selectpicker({  
				    'selectedText': 'cat'  
				});
			}
		})
	});
	$("#provexp").change(function(){//查询市
		var pid = $(this).val();
		$("#areaName").show();
		var areaid = $("#areaId").val();
		var areaname = $("#areaName").val();
		 var diag = new top.Dialog();
		 diag.Drag=true;
		 diag.Title ="请选择";
		 diag.URL = '<%=contextPath %>/area/openZtree?pid='+pid;
		 diag.Width = 250;
		 diag.Height = 400;
		 diag.CancelEvent = function(){ //关闭事件
			 var tempid = diag.innerFrame.contentWindow.document.getElementById('tempids').value;
			 var tempname = diag.innerFrame.contentWindow.document.getElementById('tempnames').value;
			if(tempid.length!==0){
				if(areaid!=''){
					var area = areaid.split(",");
					var temp = tempid.split(",");
					var len = area.length+temp.length;
					if(len<4){
						$("#areaId").val(areaid+","+tempid);
						$("#areaName").val(areaname+","+tempname);
					}else {
						swal({ 
							  title: "选择数量不能大于3个", 
							  text: "2秒后自动关闭。", 
							  timer: 2000, 
							  showConfirmButton: false 
							});
					}
				}else {
					$("#areaId").val(tempid);
					$("#areaName").val(tempname);
				}
			}
			diag.close();
		 };
		 diag.show();
	});
})
    //分配资源
	function openTree(obj,num){
	     var ids = $("#"+obj+"Id").val();
	   	 var diag = new top.Dialog();
		 diag.Drag=true;
		 diag.Title ="请选择";
		 diag.URL = '<%=contextPath %>/'+obj+'/openZtree?ids='+ids;
		 diag.Width = 250;
		 diag.Height = 400;
		 diag.CancelEvent = function(){ //关闭事件
			 var tempid = diag.innerFrame.contentWindow.document.getElementById('tempids').value;
			 var tempname = diag.innerFrame.contentWindow.document.getElementById('tempnames').value;
			if(tempid.length!==0){
				if(typeof(num)=="undefined"){ 
					$("#"+obj+"Id").val(tempid);
					$("#"+obj+"Name").val(tempname);
				}else{
					$("#"+obj+num+"Id").val(tempid);
					$("#"+obj+num+"Name").val(tempname);
				}
			}
			diag.close();
		 };
		 diag.show();
	}
var setting = {
		check: {
			enable: true,
			chkboxType: {"Y":"", "N":""}
		},
		view: {
			dblClickExpand: false
		},
		data: {
			simpleData: {
				enable: true
			}
		},
		callback: {
			beforeClick: beforeClick,
			onCheck: onCheck
		}
	};

	var zNodes =[];
	var citytemp = [];
	 $.ajax({  
	        async : false,  
	        cache:false, 
	        type: 'POST',  
	        dataType : "json",  
	        url:"<%=contextPath %>/area/getZtreeJson",
	        error: function () {//请求失败处理函数  
	            alert('请求失败');  
	        },  
	        success:function(data){ //请求成功后处理函数。   
	        	
	        	for (var i = 0; i < data.length; i++) {
	        		if(data[i].level <3){
	        			citytemp.push(data[i]);
	        		}
				}
	        		zNodes = citytemp;   //把后台封装好的简单Json格式赋给treeNodes  
	        }  
	    }); 
	function beforeClick(treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("treeDemo");
		zTree.checkNode(treeNode, !treeNode.checked, null, true);
		return false;
	}
	
	function onCheck(e, treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
		nodes = zTree.getCheckedNodes(true),
		v = "";
	    nodesid ="";
		for (var i=0, l=nodes.length; i<l;i++) {
			v += nodes[i].name + ",";
			nodesid += nodes[i].id + ",";
			if(i==2){
				break;
			}
		}
		if (v.length > 0 ) v = v.substring(0, v.length-1);
		var cityObj = $("#citySel");
		cityObj.attr("value", v);
		var cityids = $("#expectedCity");
		cityids.attr("value", nodesid);
	}

	function showMenu() {
		var cityObj = $("#citySel");
		var cityOffset = $("#citySel").offset();
		$("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");

		$("body").bind("mousedown", onBodyDown);
	}
	function hideMenu() {
		$("#menuContent").fadeOut("fast");
		$("body").unbind("mousedown", onBodyDown);
	}
	function onBodyDown(event) {
		if (!(event.target.id == "menuBtn" || event.target.id == "citySel" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
			hideMenu();
		}
	}

	$(document).ready(function(){
		$.fn.zTree.init($("#treeDemo"), setting, zNodes);
	});

	var id = $("#id").val();
	function addExperience(obj,num){
		 var ids = $("#"+obj+"Id").val();
	   	 var diag = new top.Dialog();
		 diag.Drag=true;
		 diag.Title ="请选择";
		 diag.URL = '<%=contextPath %>/'+obj+'/editView?talentsId='+id+'&num='+num;
		 diag.Width = 950;
		 diag.Height = 750;
		 diag.CancelEvent = function(){ //关闭事件
			diag.close();
		 };
		 diag.show();
	}
    function initFileInput(ctrlName) {
        var control = $('#' + ctrlName);
        control.fileinput({
        language : 'zh',
        uploadUrl : "<%=contextPath%>/upload/insert",
        //autoReplace : true,
        //showUpload:false,
        //overwriteInitial: false,
        //showCaption: false,
        showUpload: false,
        dropZoneEnabled: false,
        maxFileCount : 1,
        allowedFileExtensions : [ "jpg", "png", "gif" ],
        browseClass : "btn btn-primary", //按钮样式 
        previewFileIcon : "<i class='glyphicon glyphicon-king'></i>"
    }).on('filebatchselected', function (event, files) {//选中文件事件  
        $(this).fileinput("upload");  
    }).on("fileuploaded", function(e, data) {
        var res = data.response;
        var num=1;
        $('#' + ctrlName+num).attr("value", res.success);
    })
    }
    $("#langtype").change(function() {
    	var tid = $(this).val();
    	var language = $("#langtype2");
		$("#langtype2").show();
		if($("#langtype2").children().length > 0) {
			language.empty();
		}
		$("#langtype2").append('<option value="">==请选择==</option>');
		if(tid ==1){
	    	$.ajax({
	    		url:'<%=contextPath%>/dictionarydata/getJsonByType',
	    		data:{types:'mandarin_value'},
	    		type:'post',
	    		success:function(data){
	    			$.each(data.list,function(i,item){
	    				$("#langtype2").append("<option value="+item.value+">"+item.valueName+"</option>");
	    			});
	    		}
	    	});
		}
		if(tid ==2){
	    	$.ajax({
	    		url:'<%=contextPath%>/dictionarydata/getJsonByType',
	    		data:{types:'english_value'},
	    		type:'post',
	    		success:function(data){
	    			$.each(data.list,function(i,item){
	    				$("#langtype2").append("<option value="+item.value+">"+item.valueName+"</option>");
	    			});
	    		}
	    	});
		}
	})
    //传入id和value判断是否存在 
    function verifyName() {
    	var phone = $("#phone").val();
  	    var email = $("#email").val();
  	    if(phone!=''){
  	    	isPhone('phone',phone);
  	    }
  	    if(email!=''){
  	    	isEmail('email',email);
	    }
    	if(phone!='' && email!=''){
    		$.ajax({
    			url:'<%=contextPath%>/resume/isableName',
    			data:{'phone':phone,'email':email},
    			type:'post',
    			dataType:'json',
    			success:function(data){
    				 if(data.code==400) {
    					 swal({
       		    			title:"简历人存在重复录入，请联系管理员",
       		    			text: "2秒后自动关闭。", 
       		    			timer: 2000, 
       					    showConfirmButton: false
       		    		});
       					$("#phone").val('');
       					$("#email").val('');
    				}
    			}
    		});	
    	}
    }
</script>
</body>
</html>

